<template>
    <div class="floating">
        <ul>
            <li class="dl-row center">
                <div class="dl-row center" @click="getDetails(0)">
                    <img :src="floatImg1" alt="">
                    <p>通知公告</p>
                </div>
            </li>
            <li class="dl-row center">
                <div class="dl-row center" @click="getDetails(1)">
                    <img :src="floatImg2" alt="">
                    <p>我的任务</p>
                </div>
                <el-badge :value="todoTaskCount" :max="10" class="item tag-item" v-if="todoTaskCount>0"></el-badge>
            </li>
            <li class="dl-row center" @click="getDetails(2)">
                <div class="dl-row center">
                    <img :src="floatImg3" alt="">
                    <p>我的培训</p>
                </div>
                <el-badge :value="toDoTrainCount" :max="10" class="item tag-item" v-if="toDoTrainCount>0"></el-badge>
            </li>
            <li class="dl-row center" @click="getDetails(3)">
                <div class="dl-row center">
                    <img :src="floatImg4" alt="">
                    <p>我的收藏</p>
                </div>
            </li>
        </ul>
    </div>
</template>

<script>
    import { getToken } from '@/utils/auth';
    import { getMyTaskAndTrainNum } from '@/api/task'
    export default {
        data() {
            return {
                floatImg1: require('../assets/image/fl01.png'),
                floatImg2: require('../assets/image/fl02.png'),
                floatImg3: require('../assets/image/fl03.png'),
                floatImg4: require('../assets/image/fl04.png'),
                todoTaskCount: 0,
				toDoTrainCount:0,
            }
        },
        created() {
            this.$nextTick(() => {
                if (getToken()) {
                    this.getTaskAndTrainCount()
                }
            })
        },
        methods: {
            getDetails(type) {
                this.$router.push({
                    path: '/bayWindow',
                    query: {
                        "active": type
                    }
                })
            },
            getTaskAndTrainCount() {
                const params = {}
                getMyTaskAndTrainNum(params).then(res => {
                    this.todoTaskCount = res.myTaskNumer
					this.toDoTrainCount = res.myTrainNumer
                })
            }
        }

    }
</script>

<style>
</style>
